ΠΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠ΅ΡΠ΅Π²ΡΡ
ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ
ΠΠΎΠ½ΠΊΡΠ΅ΡΠ½ΡΠ΅ ΡΠ΅Π°Π»ΠΈΠ·Π°ΡΠΈΠΈ Π°Π±ΡΡΡΠ°ΠΊΡΠ½ΡΡ
ΠΊΠ»Π°ΡΡΠΎΠ²
class Router : public NetworkDevice {
private:
int portCount;
vector<string> routingTable;
public:
Router(const string& id, const string& maker, int ports)
: NetworkDevice(id, maker), portCount(ports) {}
void configure() override {
cout << "Configuring router with " << portCount << " ports" << endl;
}
void start() override {
cout << "Starting router " << deviceId << endl;
isActive = true;
}
void stop() override {
cout << "Stopping router " << deviceId << endl;
isActive = false;
}
void addRoute(const string& destination) {
routingTable.push_back(destination);
}
};
class Switch : public NetworkDevice {
private:
int portCount;
bool managed;
public:
Switch(const string& id, const string& maker, int ports, bool isManaged)
: NetworkDevice(id, maker), portCount(ports), managed(isManaged) {}
void configure() override {
cout << "Configuring " << (managed ? "managed" : "unmanaged")
<< " switch with " << portCount << " ports" << endl;
}
void start() override {
cout << "Starting switch " << deviceId << endl;
isActive = true;
}
void stop() override {
cout << "Stopping switch " << deviceId << endl;
isActive = false;
}
};